package com.example.security.handle;

import org.springframework.http.HttpStatus;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @application:
 * @author: LiYuhang
 * @Date: 2021/5/29 21:35
 * @version: 0.1
 * @Description :
 * @Modified By:
 */
public class MyAccessDeniedHandler implements AccessDeniedHandler {
    @Override
    public void handle(HttpServletRequest request,HttpServletResponse response,AccessDeniedException accessDeniedException) throws IOException, ServletException {
        ResponseMsg.response(response,map->{
            map.put("code",HttpStatus.BAD_REQUEST.value());
            map.put("msg","禁止访问");
        });
    }
}
